//
//  DoorSendCodeModel.m
//  RONGAO
//
//  Created by make on 2017/3/2.
//  Copyright © 2017年 wei wang. All rights reserved.
//

#import "DoorSendCodeModel.h"
#import "NSString+FIDMatch.h"
@implementation DoorSendCodeModel


- (NSString *)getSendCmd{
    
   NSString *string = [NSString stringWithFormat:@"06%@",_dataCode];
    
    return string;
}

- (NSString *)getReadCmd{
    
    NSString *string = [NSString stringWithFormat:@"EEEE000a00F00103%@%@",_funCode,_dataCode];
    
    return string;
}

- (void)repairZero:(NSString *)code
{
    
    //未补0的16进制数据
    NSString *dataCode = [NSString decimalToHexadecimal:[code integerValue]];
    NSMutableString *zero = [NSMutableString string];
    NSInteger leng = 2 - dataCode.length;
    for (int i = 0; i < leng; i++) {
        [zero appendString:@"0"];
    }
    
    NSString *string = [NSString stringWithFormat:@"%@%@",zero,dataCode];
    self.dataCode = string;
}




- (NSString *)getfunCodeWithIndex:(NSInteger)selectIndex
{
    switch (selectIndex) {
        case 0:
            self.funCode = @"1001";
            break;
        case 1:
            self.funCode = @"1002";
            break;
        case 2:
            self.funCode = @"1003";
            break;
        case 3:
            self.funCode = @"1004";
            break;
        case 4:
            self.funCode = @"1005";
            break;
        case 5:
            self.funCode = @"1006";
            break;
        case 6:
            self.funCode = @"1007";
            break;
        case 7:
            self.funCode = @"1008";
            break;
        case 8:
            self.funCode = @"1009";
            break;
        case 9:
            self.funCode = @"100A";
            break;
        case 12: //速度
            self.funCode = @"100D";
            break;
        case 13: //开门停留
            self.funCode = @"100E";
            break;
        default:
            break;
    }
    
    return self.funCode;
}

- (void)getDateCodeWithIndex:(NSInteger)index{

    switch (index) {
        case 0:
            [self repairZero:@"2"];
            break;
        case 1:
            [self repairZero:@"3"];
            break;
        case 2:
            [self repairZero:@"4"];
            break;
        case 3:
            [self repairZero:@"1"];
            break;
        case 4:
            [self repairZero:@"0"];
            break;
        default:
            break;
    }

}
@end
